package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbContentCategoryMapper;
import com.dongdongshop.pojo.GoodsVO;
import com.dongdongshop.pojo.TbContentCategory;
import com.dongdongshop.service.ContentCategoryService;
import com.dongdongshop.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description
 * @ClassName ContentCategoryServiceImpl
 * @Author RC
 * @date 2020.12.16 15:00
 */
@Component
@Service
public class ContentCategoryServiceImpl implements ContentCategoryService {
    @Autowired
    private TbContentCategoryMapper tbContentCategoryMapper;

    @Override
    public PageBean<TbContentCategory> getContentCategoryList(Integer pageNumber, Integer pageSize, String name) {
        PageBean page = new PageBean();
        page.setPageNumber(pageNumber);
        page.setPageSize(pageSize);
        List<TbContentCategory> list = tbContentCategoryMapper.getContentCategoryList(page.getStartIndex(),pageSize,name);
        //分页查询
        int i = tbContentCategoryMapper.selectCounts();
        page.setTotalCount(i);
        page.setResult(list);
        return page;
    }
    //保存
    @Override
    public void saveContentCagetory(TbContentCategory contentCategory) {
        tbContentCategoryMapper.insertSelective(contentCategory);
    }
    //回显
    @Override
    public TbContentCategory getcontentCategoryById(Long id) {
        return tbContentCategoryMapper.selectByPrimaryKey(id);
    }
    //修改
    @Override
    public void updateContentCagetory(TbContentCategory contentCategory) {
        tbContentCategoryMapper.updateByPrimaryKeySelective(contentCategory);
    }
    //删除
    @Override
    public void deleteContentCagetory(Long[] ids) {
        tbContentCategoryMapper.deleteContentCagetory(ids);
    }
    //查询所有返回广告管理页
    @Override
    public List<TbContentCategory> getContentCategoryAllList() {
        return tbContentCategoryMapper.selectByExample(null);
    }
}
